package testgrails

class Listing {
	
/*	
A Bid represents a Customer specifying a price they are willing to pay for a Listing. Bids have the following requirements:
B-1: Bids have the following required fields: amount and date/time of bid (unit test)
B-2: Bids are required to be for a Listing (unit test)
B-3: Bids are required to have a bidder (Customer) (unit test)
B-4: A Listing has a list of Bids for that Listing (unit test)
B-5: The Bid amount must be at least .50 higher than the previous Bid for the same listing (integration test)
B-6: When a Listing is saved, any new Bids added for the listing must be saved (integration test)
*/
	
	String name
	Date endDate
	Double startingBidPrice
	String description
	
	Customer seller
	Customer winner

	List bids
	static hasMany = [bids: Bid]
	
    static constraints = {

		description(nullable: true, maxSize: 255)
		endDate(min: new Date() + 1)
		name(maxSize:64)
		winner(nullable: true)
		
    }
}

/**
  MC -- Looks similar to mine for the most part.
  Again, I think the winner and seller need to be declared as relationships like this:
  
  static hasOne = [winner: Customer,seller: Customer]
  
  Also the "List bids" declaration is not necessary (unless you need it to be a List for some of your logic -- it defaults to being a java.util.Set
  
  Not sure if your endDate validator works right..  The + 1 will increment it to tomorrow, but you could have an endDate the same day  (A date in Java includes time data too)
  
  In mine I used a custom validator which just checks to makes sure the date/time is after the current date/time  (new Date() initializes a date/Time set to the current time)
  
  		endDateTime(nullable: false,
			validator: {val, obj ->
				val > new Date()
			})
*/
